using System;
using System.Globalization;

namespace Payroll
{
	public class BiWeeklySchedule : PaymentSchedule
	{
		public bool IsPayDate(DateTime payDate)
		{
			//return payDate.DayOfWeek == DayOfWeek.Friday && payDate.Day % 2 == 0;
			var cal = new GregorianCalendar();
			var weekNum = cal.GetWeekOfYear(payDate, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
			bool isBiweek = weekNum % 2 == 0;
			bool isFriday = DayOfWeek.Friday == payDate.DayOfWeek;

			return isBiweek && isFriday;
		}

		public DateTime GetPayPeriodStartDate(DateTime date)
		{
			return date.AddDays(-13);
		}

		public override string ToString()
		{
			return "bi-weekly";
		}
	}
}